#ifndef SOLUTION_H_
#define SOLUTION_H_
class Solution {
public:
    bool isPalindrome(int x) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function

        typedef unsigned int uint;
		typedef unsigned long long ull;
		if(x<0)
			return false;

		uint bx = x>0?x:(~x + 1);
		if(bx == 0)
			return true;

		uint tbx = bx;

		size_t nbits = 0;
		ull nten = 1;
		while(tbx>0)
		{
			tbx /= 10;
			nbits++;
			nten *= 10;
		}

		if(nbits==1)
			return true;

		nten /= 10;
		tbx = bx;
		while(tbx>=10)
		{
			uint top = tbx/nten;
			uint bot = tbx % 10;
			if(top != bot)
				return false;
			tbx %= nten;
			tbx /= 10;
			nten /= 100;
		}

		return true;		
    }
};
#endif
